#pragma once
//============================================================================
// Copyright (C) 2009-2013 Brett R. Jones
//
// Issued to public domain 2013
//
// brettjones1900@gmail.com
// http://www.p2panarchy.com
//============================================================================

class VxBuffer
{
	char *				m_pBuf;
	int					m_iBufUsedLen;
	int					m_iBufAllocTotalLen;
	int					m_iBufAllocBlockLen;

public:
	VxBuffer( int iPreAllocSize = 512, int iReallocSize = 1024 );
	virtual ~VxBuffer();

	int			length();
	char *		getDataPtr( void );

	void		addData( char * pData, int iLen, bool nullTerminate = true );
	int			readData( char * pData, int iLenToRead, int iReadOffs = 0, bool nullTerminate = true );
	int			readAndRemoveData( char * pData, int iLenToRead, int iReadOffs = 0, bool nullTerminate = true );
	int			removeData( int iLen, int iOffs = 0 );

	char *		getWriteBuffer( int iBufferLen );
	void		bytesWritten( int iBytesWritten, bool nullTerminate = true );
	
	void		clear();
	void		resize( int iAllocLenRequired );
};

